//
//  SettingsViewController.m
//  Timer
//
//  Created by Ashish Tarhalkar on 6/4/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "SettingsViewController.h"
#import "Settings.h"

@implementation SettingsViewController

@synthesize settings, persister;

- (IBAction) SaveSettings {

	NSString *string = textFieldTimer1.text;
	settings.timer1 = [string intValue];
	
	string = textFieldTimer2.text;
	settings.timer2 = [string intValue];
	
	[persister setInteger:settings.timer1 forKey:@"timer1"];
	[persister setInteger:settings.timer2 forKey:@"timer2"];
	[persister synchronize];
	
	[self dismissModalViewControllerAnimated:YES];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	
	[super viewDidLoad];
    
	textFieldTimer1.text = [NSString stringWithFormat:@"%d", settings.timer1];
	textFieldTimer2.text = [NSString stringWithFormat:@"%d", settings.timer2];
}


/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/



/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)viewWillAppear:(BOOL)animated {

	[super viewWillAppear:animated];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
